package efr.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;

public class EfrAdmUtil {

	/**
	 * @param args
	 * @throws EfrAdminException 
	 */
	private static Logger logger = Logger.getLogger(EfrAdmUtil.class.getName()); 
	public static Date convertStringToDate(String dateInString, String pattern) throws EfrAdminException {
		SimpleDateFormat formatter = new SimpleDateFormat(pattern);
		Date date = null;
		try {
			date = formatter.parse(dateInString);
		} catch (ParseException e) {
			logger.error("Error: ", e);
			throw new EfrAdminException("ERROR: "+dateInString+" cannot be converted in a date with the pattern "+pattern, e);
			
		}
		return date;
	}
}
